<?php

namespace app\index\controller;

use app\common\CommonController;
use app\index\service\ImportexportService;
use app\index\service\NewproductauditService;

class Newproductaudit extends CommonController
{
    public function __construct(){
        parent::__construct();
    }

    /**
     * 资料包列表
     * @author LSH
     * @return json
     */
    public function getDatagramList(){
        $data = NewproductauditService::getManufactureList($this->param);
        exitJson($data);
    }

    /**
     * 资料包导出
     * @author LSH
     * @return json
     */
    public function exportDatagramList()
    {
        $this->param['actionAsync'] = "\app\index\service\NewproductauditService::getManufactureList";
        $result = ImportexportService::exportLogic($this->param, 6);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 资料包导入
     * @author LSH
     * @return array
     */
    public function uploadDatagramListInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::uploadManufactureListInfo";
        $result = ImportexportService::importTask($param, 7,2);
        exitJson($result);
    }

    /**
     * 样品列表
     * @author LSH
     * @return json
     */
    public function getSampleList(){
        $data = NewproductauditService::getManufactureList($this->param);
        exitJson($data);
    }

    /**
     * 样品导出
     * @author LSH
     * @return json
     */
    public function exportSampleList()
    {
        $this->param['actionAsync'] = "\app\index\service\NewproductauditService::getManufactureList";
        $result = ImportexportService::exportLogic($this->param, 8);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 样品导入
     * @author LSH
     * @return array
     */
    public function uploadSampleListInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::uploadManufactureListInfo";
        $result = ImportexportService::importTask($param, 9,2);
        exitJson($result);
    }

    /**
     * 新品分派列表
     * @author LSH
     * @return json
     */
    public function getNewProductAssignList(){
        $data = NewproductauditService::getNewProductAssignList($this->param);
        exitJson($data);
    }

    /**
     * 新品分派导出
     * @author LSH
     * @return json
     */
    public function exportNewProductAssignList()
    {
        $this->param['actionAsync'] = "\app\index\service\NewproductauditService::getNewProductAssignList";
        $result = ImportexportService::exportLogic($this->param, 10);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 新品分派导入
     * @author LSH
     * @return array
     */
    public function uploadNewProductAssignInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::uploadSampleListInfo";
        $result = ImportexportService::importTask($param, 11,2);
        exitJson($result);
    }

    /**
     * 编辑审核列表
     * @author LSH
     * @return json
     */
    public function getEditAuditList(){
        $data = NewproductauditService::getEditImgAuditList($this->param);
        exitJson($data);
    }

    /**
     * 编辑审核导出
     * @author LSH
     * @return json
     */
    public function exportEditAuditList()
    {
        $this->param['actionAsync'] = "\app\index\service\NewproductauditService::getEditImgAuditList";
        $this->param['type'] = 'edit';
        $result = ImportexportService::exportLogic($this->param, 12);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 编辑审核导入
     * @author LSH
     * @return array
     */
    public function uploadEditAuditInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::uploadEditImgAuditInfo";
        $param['type'] = 'edit';
        $result = ImportexportService::importTask($param, 13,2);
        exitJson($result);
    }

    /**
     * 图片审核列表
     * @author LSH
     * @return json
     */
    public function getImgAuditList(){
        $data = NewproductauditService::getEditImgAuditList($this->param);
        exitJson($data);
    }

    /**
     * 图片审核导出
     * @author LSH
     * @return json
     */
    public function exportImgAuditList()
    {
        $this->param['actionAsync'] = "\app\index\service\NewproductauditService::getEditImgAuditList";
        $this->param['type'] = 'img';
        $result = ImportexportService::exportLogic($this->param, 14);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 图片审核导入
     * @author LSH
     * @return array
     */
    public function uploadImgAuditInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::uploadEditImgAuditInfo";
        $param['type'] = 'img';
        $result = ImportexportService::importTask($param, 15,2);
        exitJson($result);
    }

    //打回到交接
    public function deleteAudit(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewproductauditService::deleteAudit";
        $result = ImportexportService::importTask($param, 52,2);
        exitJson($result);
    }

    /**
     * 新品分派
     * @author LSH
     * @return json
     */
    public function insertAssignInfo(){
        $rules = [
            'id' => 'require',
            'sku' => 'require',
            'type' => 'require',
            'operator' => 'require'
        ];
        $this->validateData($rules);
        if(NewproductauditService::insertAssignInfoLogic($this->param))
            returnJson();
        else
            returnJson('0','操作失败');
    }

    /**
     * 样品归还
     * @author LSH
     * @return json
     */
    public function updateSampleReturn(){
        $rules = [
            'id' => 'require',
            'people' => 'require'
        ];
        $this->validateData($rules);
        $data = NewproductauditService::updateSampleReturnLogic($this->param);
        returnJson($data);
    }

    /**
     * 图片/编辑审核
     * @author LSH
     * @return json
     */
    public function updateMaterialAudit(){
        $rules = [
            'id' => 'require',
            'type' => 'require',
            'status' => 'require'
        ];
        $this->validateData($rules);
        $code = NewproductauditService::updateMaterialAuditLogic($this->param);
        $msg = ($code == 0)?'操作失败':'成功';
        returnJson($code,$msg);
    }

    /**
     * 审核
     * @author LSH
     * @return json
     */
    public function updateManufactureAudit(){
        $rules = [
            'id' => 'require',
            'sku' => 'require',
            'status' => 'require'
        ];
        $this->validateData($rules);
        $data = NewproductauditService::updateManufactureAuditLogic($this->param);
        returnJson($data);
    }
}